package filemanager;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;

import core.Client;
import core.Program;

public class FileManager {

	// TODO: Bisogna eliminare tutte le cartelle di programmi non più associati
	
	public void init()
	{
		HashMap<String, Program> associatedPrograms = Client.getInstance().getAssociatedPrograms();
		
		String mainDir = Client.getInstance().getConfigs().get("mainDir");
		
		File dir;
		String programName;
		for (Iterator iterator = associatedPrograms.keySet().iterator(); iterator.hasNext();)
		{
			programName = (String) iterator.next();
			dir = new File(mainDir, programName);
			if(!dir.exists())
				dir.mkdir();	
		}	
	}
	
	public static boolean deleteFile(String filePath)
	{
		File file = new File(filePath);
		if(file.delete())
			return true;
		
		return false;
	}
}
